/**
 * @author Greg Winn
 * VERSION: 1.0.1
 * Project Website: trakitnow.com
 * 
 * This is used with Prototype
 * started 03-21-2008
 * last update 05-06-2008
 */
function Winnjs() {
	
	this.countHit = function (hit_type, headers, options) {
		if (hit_type != null || headers != null) {
			var ext_options = '';
			var optcount = options.length;
			var getoptcount = 0;
			function getOptions(element){
				getoptcount += 1;
				optarray = element.split(":");
				if (optarray[0] == 'responce') {
					optarray[1] == 'true' ? alertme = true : alertme = false;
				}else{
					alertme = false;
				}
				if(getoptcount == optcount) {
					ext_options += optarray[0] + ":" + optarray[1];
				}else{
					ext_options += optarray[0] + ":" + optarray[1] + ";";
				}
			}
			if (options != null || options != '') {
				options.forEach(getOptions);
			}
			else {
				ext_options = '';
			}
			
			var theRequestUrl = 'classes/hit.php';
			
			if(alertme == true) {
				showalert = function(transport){
						      var response = transport.responseText || "no response text";
						      alert("Responce from Tracking: " + response);
						    }
			}else{
				showalert = '';
			}
			
			// Make the call to Prototype
			new Ajax.Request(theRequestUrl, {
				method: 'get',
				onSuccess: showalert,
				parameters: {
					hit_type: hit_type,
					headers: headers,
					options: ext_options,
					jssend: 'true'
				}
			});
		}
		
	}
	
}
var Winnjs = new Winnjs();
// now call with: Winnjs.hit('','',['']);